package com.flong.spring.bean;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.ComponentScan;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @Author:liangjl
 * @Date: 2020/6/10-21:40
 * @Eamil:jilongliang@sina.com
 * @Description:
 */

@ComponentScan
public class Dog implements ApplicationContextAware {

    private ApplicationContext applicationContext;

    public Dog() {
        System.out.println("Dog constructor");
    }


    /**
     * 对象创建并赋值
     */
    @PostConstruct
    public void init() {
        System.out.println("Dog PostConstruct");
    }

    @PreDestroy
    public void destory() {
        System.out.println("Dog destory");
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
